package cn.jszhao.eform.controller;

import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import cn.jszhao.eform.entity.EformDataEntity;
import cn.jszhao.eform.service.EformDataService;
import cn.jszhao.common.utils.PageUtils;
import cn.jszhao.common.utils.R;



/**
 * 表单模板信息标
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2024-08-07 16:35:17
 */
@RestController
@RequestMapping("eform/eformdata")
public class EformDataController {
    @Autowired
    private EformDataService eformDataService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = eformDataService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{dataId}")
    public R info(@PathVariable("dataId") Long dataId){
		EformDataEntity eformData = eformDataService.getById(dataId);

        return R.ok().put("eformData", eformData);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody EformDataEntity eformData){
		eformDataService.save(eformData);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody EformDataEntity eformData){
		eformDataService.updateById(eformData);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] dataIds){
		eformDataService.removeByIds(Arrays.asList(dataIds));

        return R.ok();
    }

}
